package processer

import (
	"encoding/json"
	"github.com/siddontang/go-log/log"
	"hermes/load"
	"hermes/message"
)

func SendMessage(processMessage *message.ProcessMessage)  {
	loadMessage := message.LoadMessage{
		TableName:processMessage.TableName,
		OpType:processMessage.Operation,
		LogPositionName:processMessage.Position.Name,
		LogPosition:processMessage.Position.Pos,
		TableColumnNames:processMessage.TableColumnNames,
		TableColumnTypes:processMessage.TableColumnTypes,
		Rows:processMessage.Rows,
	}
	data, err := json.Marshal(loadMessage)
	if err == nil {
		load.KafkaSend(processMessage.TableName,data)
	}else {
		log.Error(err)
	}
}